import React from 'react';
import styles from './index.less';

export default ({ value, options = [], onChange = () => {} }) => {
  return (
    <div className={styles.segmented}>
      {options.map((item) => (
        <div
          key={item.value}
          className={value === item?.value ? styles.active : ''}
          onClick={() => {
            if (value === item.value) return;
            onChange?.(item.value, item);
          }}
        >
          {item?.label || ''}
        </div>
      ))}
    </div>
  );
};
